package com.xinyue.gateway.server.handler;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
import com.xinyue.gateway.server.message.GateMessagePackage;
import com.xinyue.network.message.InnerMessageCodecFactory;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;

/**
 * 
 * @author 心悦网络科技有限公司 王广帅
 * @desc   将收到客户端请求包转化为内网转输的包，并发送出去。
 * @Date 2018年6月14日 下午6:22:07
 */
@Service
@Scope(scopeName = "prototype")
public class InnerPackageEncodeHandler extends ChannelInboundHandlerAdapter {
	private static Logger logger = LoggerFactory.getLogger(InnerPackageEncodeHandler.class);
	InnerMessageCodecFactory codecFactory = InnerMessageCodecFactory.getInstance();

	@Override
	public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
		if(msg instanceof GateMessagePackage) {
		    GateMessagePackage gateMessagePackage = (GateMessagePackage) msg;
		    
		}
	}

	@Override
	public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
		logger.error("服务器异常", cause);
	}
}
